<template>
	<!-- 历史项目图纸 -->
	<div>
		<div style="height:3000px">
			<v-card>
				<v-card-title>
					<v-row class="mt-2">
						<v-col cols="12" sm="3" md="2">
							<v-text-field label="项目号" v-model="projectQuery.projectcode" dense outlined>
							</v-text-field>
						</v-col>
						<v-col cols="12" sm="3" md="2">
							<v-text-field label="零部件名称" v-model="projectQuery.name" dense outlined>
							</v-text-field>
						</v-col>
						<v-col cols="12" sm="3" md="2">
							<v-text-field label="图号" v-model="projectQuery.piccode" dense outlined>
							</v-text-field>
						</v-col>
						<v-col>
							<v-btn color="primary" @click="LoadPage">查询</v-btn>
							<v-btn class="ml-3" depressed color="primary" @click="RefreshApps">
								刷新</v-btn>
						</v-col>
					</v-row>
				</v-card-title>
				<v-card-text>
					<v-data-table :headers="projectHeaderList" :items="projectDataList" small fixed-header item-key="id"
						dense class="text-no-wrap" loading-text="正在加载请稍等......" :loading="projectLoading"
						:options.sync="projectOptions" :footer-props="vuetifyDefaultPage"
						:server-items-length="projectTotalCount">
						<template v-slot:item.equiPart.picurl="{ item }">
							<a @click="openLookPicsClick(item.equiPart.picurl)">查看文件</a>
						</template>
						<template v-slot:item.detail="{ item }">
							<a @click="openDetail(item)">查看详情</a>
						</template>
					</v-data-table>
				</v-card-text>
			</v-card>

		</div>
		<showfiledialogcomment :filesModel="fileDialogComment"></showfiledialogcomment>
		<v-dialog v-model="detailDialog">
			<v-card>
				<v-card-title>详细信息</v-card-title>
				<v-card-text>
					<v-row>
						<v-col cols="12" md="3">
							<v-text-field v-model="part.jgcode" label="加工件编码"></v-text-field>
						</v-col>
						<v-col cols="12" md="3">
							<v-text-field v-model="part.keypathname" label="bom结构路径名称"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.name" label="名称"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.piccode" label="图号"></v-text-field>
						</v-col>
						<v-col cols="12" md="1">
							<v-text-field v-model="part.model" label="产品型号"></v-text-field>
						</v-col>
						<v-col cols="12" md="1">
							<v-text-field v-model="part.versioncode" label="版本号"></v-text-field>
						</v-col>


						<v-col cols="12" md="2">
							<v-text-field v-model="part.bomtypename" label="BOM类型名称"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.bomchildrentypename" label="bom子类型名称"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.assemblydate" label="装配需求日"></v-text-field>
						</v-col>
						<v-col cols="12" md="3">
							<v-text-field v-model="part.surface_treatment" label="表面处理"></v-text-field>
						</v-col>
						<v-col cols="12" md="3">
							<v-text-field v-model="part.process" label="工艺"></v-text-field>
						</v-col>

						<v-col cols="12" md="2">
							<v-text-field v-model="part.real_material_qty" label="实际用料数量"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.real_material_unit" label="单位"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.real_material_single_qty" label="实际用料单套数量"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.real_material_specifications" label="实际用料规格"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.real_material_name" label="实际用料名称"></v-text-field>
						</v-col>
						<v-col cols="12" md="2">
							<v-text-field v-model="part.real_material_code" label="实际用料编码(存货编码)"></v-text-field>
						</v-col>
					</v-row>
				</v-card-text>
				<v-card-actions>
					<v-spacer></v-spacer>
					<v-btn color="red" class="mr-4" text @click="detailDialog=false">关闭</v-btn>
				</v-card-actions>
			</v-card>
		</v-dialog>
	</div>
</template>

<script>
	import showfiledialogcomment from '../../comments/ShowFilesDialog.vue'
	export default {
		name: 'document_history',
		components: {
			showfiledialogcomment
		},
		data: () => ({
			projectQuery: {
				projectcode: '',
				name: '',
				piccode: ''
			},
			detailDialog: false,
			part: {},
			projectHeaderList: [{
					text: '项目号',
					align: 'left',
					value: 'projectcode',
					filterable: false,
				},
				{
					text: '项目名称',
					align: 'left',
					value: 'projectname',
					filterable: false,
				},
				{
					text: '零部件名称',
					align: 'left',
					value: 'name',
					filterable: false,
				},
				{
					text: '图号',
					align: 'left',
					value: 'piccode',
					filterable: false,
				},
				{
					text: '查看文件',
					align: 'center',
					value: 'equiPart.picurl',
					filterable: false,
					class: 'fixed'
				},
				{
					text: '查看详情',
					align: 'center',
					value: 'detail',
					filterable: false,
					class: 'fixed'
				},
				{
					text: '修改时间',
					align: 'center',
					value: 'created_time',
					filterable: false,
					class: 'fixed'
				},
				{
					text: '修改人',
					align: 'center',
					value: 'created_byname',
					filterable: false,
					class: 'fixed'
				},
			],
			projectDataList: [],
			projectTotalCount: 0,
			projectLoading: true,
			projectOptions: { //页数
				page: 1,
				//每页行数
				itemsPerPage: 50
			},
			vuetifyDefaultPage: {
				'items-per-page-text': '每页个数',
				'items-per-page-options': [50, 100, 300, 500]
				// 'items-per-page-all-text': '100'
			},
			fileDialogComment: {
				dialog: false,
				files: []
			},
		}),
		watch: {
			projectOptions: {
				handler() {
					this.LoadPage()
				},
				deep: true
			},
		},
		methods: {
			RefreshApps() {
				this.projectQuery.projectcode = ''
				this.projectQuery.name = ''
				this.projectQuery.piccode = ''
			},
			//查看图片
			openLookPicsClick(pathstrs) {
				this.fileDialogComment.dialog = true
				this.fileDialogComment.files = JSON.parse(pathstrs)
			},
			async LoadPage() {
				this.systemLogLoading = true
				var response = await this.$httpRequest({
					url: `PDM/PDMDocumentHistory/LoadPage?projectcode=${this.projectQuery.projectcode}&piccode=${this.projectQuery.piccode}&name=${this.projectQuery.name}&pageNumber=${this.projectOptions.page}&pageSize=${this.projectOptions.itemsPerPage}`,
					method: 'get',
				})
				if (response.status == 1) {
					this.projectDataList = response.data.result
					this.projectTotalCount = response.data.pagination.totalRecords
					this.projectLoading = false
				} else {
					this.$message.error(response.info)
				}
			},
			openDetail(item) {
				this.detailDialog = true
				this.part = item.equiPart
			},
		},
	}
</script>


<style>
</style>
